<?php  
	include("../includes/connect_db.php");
	session_start();

	$username 	 = strtolower($_POST['username']);
	$password 	 = md5($_POST['password']);
	$act 		 = $_POST['act'];

	switch ($act) {
		case '1':
			$sql_user = "SELECT * FROM user WHERE username = '$username'";
			$query_user = mysql_query($sql_user);
			if (mysql_num_rows($query_user) > 0) {
				$user = mysql_fetch_array($query_user);
				if ($user['password'] == $password) {
					$_SESSION['idUser'] = $user["id"];
					echo "sukses";
				} else {
					echo "gagal";
				}
			} else {
				echo "gagal";
			}
			break;

		case '2':
			session_destroy();
			break;
	}
?>